﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RevClinic.Core.Domain
{
    public class UserGroup : Entity<long>
    {
        public virtual string Name { get; set; }
        public virtual IList<UserRole> Roles { get; set; }

        public UserGroup() { }

        public UserGroup(UserType type)
            : this(type.ToString())
        {
        }

        public UserGroup(string name)
        {
            Name = name;
            Roles = new List<UserRole>();
        }

        public virtual void AddRole(UserRole role)
        {
            //remove roles that are childs of new role
            if (Roles.Contains(role) == false) {
                //_roles = _roles.Where(r => !r.IsChildOf(role)).ToList();
                Roles.Add(role);
            }
        }

        public virtual void RemoveRole(UserRole role)
        {
            Roles.Remove(role);
        }

    }
}
